all: re-implement state overriding#29950
Conversation
379059d to
ed88ef0
Compare
ed88ef0 to
df45370
Compare
| } | ||
|
|
||
| // OverrideState applies the state overrides into the provided live state database. | ||
| func OverrideState(state *StateDB, overrides map[common.Address]OverrideAccount) (*StateDB, error) { |
There was a problem hiding this comment.
Can we keep the StateOverride type alias? more cumbersome to type map[common.Address]OverrideAccount 😄
df45370 to
a86c1d0
Compare
3f1a846 to
460ba4d
Compare
460ba4d to
6ac43e7
Compare
|
Ah, so this one is really a follow-up on #29761 ? |
|
We had a triage discussion about this. As it stands the PR doesn't let us compute the state root off of the overridden state. This feature is desired for #27720. |
|
But I think this branch is still better than the existing solution for state override. e.g. we can use this feature to override the states for "read-only" purposes. For multicall, it's a bit different. It feels like a call simulation which may have the state mutations (but they are never persisted). In this case, we can use the existing solution to apply the overrides as mutation. |
6ac43e7 to
3232927
Compare
|
Needs a rebase |
|
I think the approach here is good.
I think that's a pretty hard criteria to judge by. That sounds like a pretty difficult thing to achieve, IMO. |
|
I can rebase it |
| } | ||
|
|
||
| // StateWithOverrides returns a new mutable state with provided state overrides. | ||
| func (bc *BlockChain) StateWithOverrides(root common.Hash, overrides *map[common.Address]state.OverrideAccount) (*state.StateDB, error) { |
There was a problem hiding this comment.
Why pass *map instead of just a map?
|
Getting back to this. So, in my branch layerd_override, I started banging out how a layered-statedb implementation of this would look. I mean, if, instead of adding the overrides in the Reader-layer below the StateDB, we instead layer it like the First of all, that approach requires the defnition of a statedb interface, basically a copy of A larger problem is that all journalling is implemented in side func (ch nonceChange) revert(s *StateDB) {
s.getStateObject(ch.account).setNonce(ch.prev)
}Because the public func (s *StateDB) SetNonce(addr common.Address, nonce uint64) {
stateObject := s.getOrNewStateObject(addr)
if stateObject != nil {
stateObject.SetNonce(nonce)
}
}
// --> invokes
func (s *stateObject) SetNonce(nonce uint64) {
s.db.journal.nonceChange(s.address, s.data.Nonce)
s.setNonce(nonce)
}All in all, my idea about putting overrides as a layer-on-top doesn't seem to be very good. Please rebase and I'm all for getting this PR merged. |
|
It was a bit tricky to rebase this. I made an attempt, here: https://github.com/ethereum/go-ethereum/compare/master...holiman:go-ethereum:override-reader-3?expand=1 , but I didn't want to force-push on your branch, because it's pretty raw. It compiles, but I haven't verified any functionality. YMMV, up to you if you want to use it or not :) |
|
I am reconsidering our direction here. A while ago, we implemented During initial discussions around The limitation of the new implementation is that it only supports read-only state overrides. Given this, I would lean toward using our existing approach: applying mutations on top of overrides, as it is compatible with both use cases. |
Yep, makes sense to me. Let's close this then |
No description provided.